package com.sqoop.client.client.destinationgenerator;

import com.sqoop.core.destnation.MqMsgDestination;
import com.sqoop.core.msg.MsgDestination;
import org.apache.commons.lang3.StringUtils;

import java.util.UUID;

/**
 * Created by zw on 2017/11/15.
 */
public abstract class AbstartFixDestinationGenerator implements DestinationGenerator{
    private String url = null;

    private String queuename = null;

    private String queuetype = null;

    //private String queueNameend = "_request_"+ UUID.randomUUID().toString();

    public AbstartFixDestinationGenerator(String url, String queuename, String queuetype) {
        this.url = url;
        this.queuename = queuename;
        this.queuetype = queuetype;
    }

    public abstract String  getQueueEnd();

    @Override
    public MsgDestination generator(Object obj) {
        MqMsgDestination destination = new MqMsgDestination();
        destination.setMqurl(url);
        String newqueuename = queuename;
        if (!StringUtils.isEmpty(getQueueEnd())){
            newqueuename = queuename +  getQueueEnd();
        }
        destination.setQueuename(newqueuename);
        destination.setQueuetype(queuetype);
        return destination;
    }
}